# coding: utf-8
import json
from pathlib import Path

from PySide6.QtCore import QRunnable

from common import Task


class DownRunnableBase(QRunnable):
    def __init__(self, task: Task):
        super().__init__()
        self.task = task
        self.tid = task.id
        self.url = task.url
        self.save_file = Path(f'{task.save_folder}/{task.file_name}')
        if isinstance(task.headers, str):
            self.headers = json.loads(task.headers)
        else:
            self.headers = task.headers

        self.setAutoDelete(True)

    def stop(self):
        raise NotImplementedError()

    def start(self):
        raise NotImplementedError()
